package com.ctech.wsgen.core;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.ctech.wsgen.model.Item;
import com.ctech.wsgen.model.ItemCategory;
import com.ctech.wsgen.model.Manufacture;
import com.ctech.wsgen.model.Site;

public class MockSite {
	
	private static final int NUM_OF_ITEM_CATEGORIES = 5;
	private static final int NUM_OF_ITEM_CATEGORIES_ITEMS = 10;
	private static final int NUM_OF_MANUFACTURES = 3;
	private static final int NUM_OF_MANUFACTURES_ITEMS = 30;
	public static final BigDecimal price = new BigDecimal(5.56);
	
	public static Site createSite() {
		Site site = new Site(createManufactures(), createItemCategories());
		site.setStr_siteDir("./target/classes/testing");
		site.setStr_email("test@testing.com");		
		return site;
	}
	
	private static List<ItemCategory> createItemCategories() {
		
		List<ItemCategory> itemCategories = new ArrayList<ItemCategory>();
		ItemCategory itemCategory;
		for (int i = 1; i < NUM_OF_ITEM_CATEGORIES; i++) {
			itemCategory = new ItemCategory(i, "VendorName " + i, "PartNum " + i, 
					"Description " + i , price , "Category_" + i + ".html", 
					"CatTitleName " + i, "GroupID " + i);
			itemCategory.setItems(createItems(NUM_OF_ITEM_CATEGORIES_ITEMS));
			itemCategories.add(itemCategory);
		}
		return itemCategories;
	}

	static List<Manufacture> createManufactures() {
		
		List<Manufacture> manufactures = new ArrayList<Manufacture>();
		Manufacture manufacture;
		for (int i = 1; i < NUM_OF_MANUFACTURES; i++) {
			manufacture = new Manufacture(i, "Manufacture " + i, "PartNum " + i, 
					"Description " + i, price, "Maufacture " + i + ".html", 
					"www.manufacture-" + i + ".com", "LogoFileName " + i);
			manufacture.setItems(createItems(NUM_OF_MANUFACTURES_ITEMS));
			manufactures.add(manufacture);
		}
		return manufactures;
	}

	private static List<Item> createItems(int numOfItems) {

		BigDecimal price = new BigDecimal(5.56);
		List<Item> items = new ArrayList<Item>();
		for (int i = 1; i < numOfItems; i++) {
			items.add(new Item(i, "VendorName " + i , "PartNum " + i, "Description " + i, price.multiply(new BigDecimal(i)), "FileName " + i));
		}
		return items;
	}

}
